/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*	
*	Julio Montes e-mail: imc.coder@gmail.com 
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#ifndef ALLIANCE_PROJECTMGR_H
#define ALLIANCE_PROJECTMGR_H

#include <wx/wx.h>

#include <map>

#include "sdk/include/mgr.h"

#include "alliance/include/project.h"

namespace alliance
{
    class ProjectsTree;

    class ProjectManager : public sdk::Mgr<ProjectManager>
    {
    public:
        static const wxString s_projectExtension;
        static wxBitmap s_imageFile;

        ProjectManager();
        virtual ~ProjectManager();

        bool Load();

        Project *GetProject( const wxString &filename );

        Project *GetActiveProject();

        ProjectsTree *GetProjectsTree() const;

        wxArrayString GetVhdlFiles();

        /**
        * @brief add new source file to active project
        *
        */
        void NewSourceFile();
        void NewPatFile();
        void NewIocFile();

        /**
        * @brief add files to active project
        *
        */
        void AddFiles( Project *project=NULL );

        void SaveProject( Project *project );

        void SaveActiveProject();

        void SaveAllProjects();

        bool CloseActiveProject();

        bool CloseAllProjects();

        bool CloseProject( Project *project );

        bool CreateProject();

        bool OpenProject( const wxString &filename );

        bool OpenProject();

        bool IsOpenProject( const wxString &filename ) const;

        void Build();

        void BuildOptions( Project *project=NULL );

        bool OnClose();

        void ActiveProject( Project *project );


    protected:
    private:
        std::map<wxString, Project> m_mapProjects;
        Project *m_activeProject;

        ProjectsTree *m_projectsTree;

        bool LoadMenu();
    };
}

#endif //ALLIANCE_PROJECTMGR_H
